<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<jsp:include page="../comunes/header.jsp" />
<h2>Listado de Reembolsos</h2>
<button type="button" class="btn_agregar" title="Agregar" 
        onclick="window.location.href = '<c:url value="/reembolsos/nuevo"/>'">Crear Reembolso</button>
<div class="pnl_scroll" id="pnl_reembolsos">
   <table class="tbl_listado">
      <thead><tr><th>N&deg;</th><th>Tipo</th><th>Descripci&oacute;n</th><th>Usuario</th>
            <th>Fecha</th><th>Monto<br/>Usuario</th><th>Monto<br/>CIA</th><th>Comprobantes</th><th>Estatus</th><th>Opc.</th></tr></thead>
      <tbody>
         <c:forEach var="reembolso" items="${reembolsos}">
            <c:url var="editUrl" value="/reembolsos/edit?nr=${reembolso.numero}" />
            <c:url var="pdfUrl" value="/reembolsos/pdf?nr=${reembolso.numero}" />
            <tr><td><c:out value="${reembolso.numero}"/></td>
               <td><c:out value="${reembolso.tipoSolicitud.descripcionCorta}" /></td>
               <td><textarea cols="25" rows="2" class="txa_descripcion" readonly="readonly">${reembolso.descripcion}</textarea></td>
               <td><c:out value="${reembolso.usuario.nombre} ${reembolso.usuario.apellidos}" /></td>
               <td><fmt:formatDate pattern="dd/MM/yyyy HH:mm:ss" value="${reembolso.fecha}" /></td>
               <td><fmt:formatNumber value="${reembolso.montoFavorUsuario}" type="currency"/></td>
               <td><fmt:formatNumber value="${reembolso.montoFavorCia}" type="currency"/></td>
               <td><a href="<c:url value="/reembolsos/deta?nr=${reembolso.numero}"/>">
                     ${fn:length(reembolso.detalles)} Gastos</a>
               <td><c:choose>
                     <c:when test="${reembolso.estatus=='R'}">Registrado</c:when>
                     <c:when test="${reembolso.estatus=='C'}">Correcci&oacute;n</c:when>
                     <c:when test="${reembolso.estatus=='P'}">En proceso</c:when>
                     <c:when test="${reembolso.estatus=='A'}">Aprobado</c:when>
                     <c:when test="${reembolso.estatus=='X'}">Rechazado</c:when>
                     <c:otherwise>Otro...</c:otherwise>
                  </c:choose>
               </td>
               <td><c:if test="${reembolso.estatus=='R' || reembolso.estatus=='C'}">
                     <button type="button" class="btn_editar" title="Editar" onclick="window.location.href = '${editUrl}'">E</button>
                  </c:if>
                  <button type="button" class="btn_pdf" title="Ver PDF"  onclick="window.open('${pdfUrl}')">PDF</button>
               </td>
            </tr>
         </c:forEach>
      </tbody>
      <tfoot><tr><td colspan="9"></td>
            <td><button type="reset" class="btn_regresar" title="Regresar">Regresar</button></td></tr>
      </tfoot>
   </table>
</div><c:url var="regrUrl" value="/reembolsos" />
<script type='text/javascript'>
   $(document).ready(function() {
      $(".btn_regresar").click(function() {
         window.history.back();
      });
   });
</script>
<jsp:include page="../comunes/footer.jsp" />